<?php

class HBaseController extends Controller
{
	// 布局文件
	public $layout ="//layouts/home";
	
	////导航焦点
	public $active_cur = '';
	
	public $pageKeyword = '';
	public $pageDesc = '';
	
	//模块URL前缀
	protected $pre_module_url;
	
	public function init(){
		$modurl = $this->module !== null ? "/".$this->module->id:"";
		$this->pre_module_url = $modurl;
	}
	//载入SEO信息
	protected function beforeAction($action) {
		//获取活动的一级菜单
		$criteria = new CDbCriteria;
		$criteria->compare('zna_type',3);
		
		$modulename = $this->pre_module_url."/";
		$criteria1 = clone $criteria;
		$criteria1->compare('zna_url',$modulename.Yii::app()->getController()->id,true);
		//如果一个控制器下存在多个菜单，则需细分
		if(Nav::model()->count($criteria1)>1){
			$criteria2 = clone $criteria;
			$criteria2->compare('zna_url',$modulename.Yii::app()->getController()->id.'/'.$action->id,true);
			$activeTop =  Nav::model()->find($criteria2);
			if(empty($activeTop))
				$activeTop =  Nav::model()->find($criteria1);
		}else{
			$activeTop =  Nav::model()->find($criteria1);
		}
		
		if(!empty($activeTop)){
			$this->pageTitle = $activeTop->zna_seotitle."-".F::setting('sitename');
			$this->pageKeyword = $activeTop->zna_seokey;
			$this->pageDesc = $activeTop->zna_seodesc;
		}
		return true;
	}
}